using System.Collections.ObjectModel;
using HMCollada.Core;
using System.Xml;

namespace HMCollada.Core {
    internal struct HMColladaVisualScene {
        internal string id;
        internal string name;
        internal HMColladaAsset asset;
        internal Collection<HMColladaNode> node;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaVisualScene LoadVisualScene() {
            HMColladaVisualScene newVisualScene = new HMColladaVisualScene();
            newVisualScene.id = colladaReader.GetAttribute("id");
            newVisualScene.name = colladaReader.GetAttribute("name");

            newVisualScene.node = new Collection<HMColladaNode>();

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "asset": newVisualScene.asset = LoadAsset(); break;
                        case "node": newVisualScene.node.Add(LoadNode()); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "visual_scene");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newVisualScene;
        }
    }
}